#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QtGui/QMainWindow>
#include "nfc.h"
#include "QsKineticScroller.h"
#include <QVBoxLayout>
#include "contactname.h"
#include <QMovie>
#include "activity.h"
#include "phdialogs.h"
#include "tagdatarequest.h"
#include <qfeedbackactuator.h>
#include <qfeedbackeffect.h>
#include <QMediaPlayer>
#include <QMediaPlayer>






namespace Ui {

class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT
public:
    enum ScreenOrientation {
        ScreenOrientationLockPortrait,
        ScreenOrientationLockLandscape,
        ScreenOrientationAuto
    };

    enum TimeOut{
        MFALSE,
        MTRUE
    };

    enum UiStates {
        ScannedTag,
        LockedState,
        RegTimeOutState,
        Ureg_ActivityState,
        SettingsState,
        UnknownParticipantState,
        ActivityState,
        ActivityDialogState,
        ActivityDialogWaitState,
        ActivityWaitForScanningState,
        ActivityUpdateStudent

    };

    explicit MainWindow(QWidget *parent = 0);
    virtual ~MainWindow();

    // Note that this will only have an effect on Symbian and Fremantle.
    void setOrientation(ScreenOrientation orientation);

    void showExpanded();

private slots:
    void on_pushButton_clicked();
    void receiveUid(QByteArray mUid);
    void on_Exit_clicked();
    void on_settings_2_clicked();


    void setSettingsFrameTrans(int aValue);
    void setLockedFrameTrans(int aValue);
    void setUnLockedFrameTrans(int aValue);
    void setActivityFrameTrans(int aValue);
    void setUnRegActivityFrameTrans(int aValue);




    void on_pushButton_2_clicked();
    void on_pushButton_3_clicked();

private:
    Ui::MainWindow *ui;
    NFC *m_NFC_manager;
    UiStates mUistate;
    TimeOut mTimeOut;
    bool mNetworkTimeOut;
    QTimer *timer;

    QList<contactName*> mScrollElevPtr;
    QsKineticScroller *mScroll,*mScrollContact;
    QVBoxLayout *vBoxScroll;
    contactName *mContactName;
    QMovie *movie;
    int mTimerCount;
    QByteArray m_NFCUID;
    Activity *mActivityObj;
    TagDataRequest *mTagObj;
    QByteArray mStudentUID;
    QString mStudentName;
    PhDialogs *mDialog;
    //Settings var
    bool mAudioFeedback;

    QString mIPAddr;



    //Functions
    void writeSettings();
    void readSettings();
    void init();
    void newActivity();
    void feedBack();
    void playStudentTag();
    void playTeacherTag();
    void playError();

    //Activity view function
    void setActivityView();
    void initActivityView();
    void clearActivityView();
    void addContact();
    void startTimer();
    void stopTimer();
    void setPresent();

    //Statemashine functions
    void processScannedTag(UiStates mState);
    void updateState(UiStates mState);
    void processLockState(UiStates mState);
    void processActivityState(UiStates mState);
    void processSettingsState(UiStates mState);
    void processActivityDialogState(UiStates mState);
    void processURegActivityState(UiStates mState);
    void processActivityWaitForScanningState(UiStates mState);
    void processActivityUpdateStudent(UiStates mState);
    void processUnkonwnParicipantState(UiStates mState);


private slots:
    void activityUpdate(Activity::ActivityStatus mStatus);
    void timeOut(int mTimeOut);
    void studentClicked(QByteArray aUID,QString aStudentName);
    void dialogCancel();

private slots:
    void statusChanged(QMediaPlayer::MediaStatus status);
    void on_soundFeedback_clicked(bool checked);

private:
    QMediaPlayer *m_pPlayer;



};

#endif // MAINWINDOW_H
